Kameleon-Plus  0.3.2
Model.h
Go to the documentation of this file.
1 /*
2  * Model.h
3  *
4  * Created on: Jun 2, 2009
5  * Author: David Berrios
6  */
7 
8 #ifndef MODEL_H_
9 #define MODEL_H_
10 #include <string>
11 #include <map>
12 #include <vector>
13 #include <boost/unordered_map.hpp>
14 
15 #include "GeneralFileReader.h"
16 #include "Interpolator.h"
17 
18 namespace ccmc
19 {
20  class Interpolator;
27  class Model: public GeneralFileReader
28  {
29 
30  public:
31  Model();
32 
33  static const int BUSY=1;
34  static const int OK=2;
35 
43  virtual long open(const std::string& filename) = 0; //the individual models need a different open method
44  void setModelName(std::string modelName);
45  std::string getModelName();
46 
47  long loadVariable(const std::string& variable);
48  long unloadVariable(const std::string& variable);
49  long loadVariableInt(const std::string& variable);
50 
51  std::vector<float>* getVariableFromMapRW(const std::string& variable);
52  std::vector<int>* getIntVariableFromMapRW(const std::string& variable);
53  const std::vector<float>* const getVariableFromMap(const std::string& variable);
54  const std::vector<int>* const getIntVariableFromMap(const std::string& variable);
55 
56  void addFloatVariableToMap(const std::string& variable, std::vector<float>* variableData);
57 
58  const std::vector<float>* const getVariableFromMap(long variable_id);
59  const std::vector<int>* const getIntVariableFromMap(long variable_id);
60 
61  std::vector<float>* getVariableFromMapRW(long variable_id);
62  std::vector<int>* getIntVariableFromMapRW(long variable_id);
63 
64  virtual const std::vector<std::string> getLoadedVariables();
65 
66  void setMissingValue(float missingValue);
67  float getMissingValue();
68  float getConversionFactorToSI(const std::string& variable);
69  std::string getNativeUnit(const std::string& variable);
70  std::string getSIUnit(const std::string& variable);
71  int getProgress();
72  int getBusyStatus();
73 
74 
75  long close();
76 
84  virtual Interpolator* createNewInterpolator() = 0;
85 
86  //const FileReader& getFileReader();
87  virtual ~Model();
88 
89  protected:
90  //only need these for the BOOST_FOREACH macro to work
91  typedef boost::unordered_map<std::string, std::vector<float>*> mapStringFloat;
92  typedef boost::unordered_map<std::string, std::vector<int>*> mapStringInt;
93  typedef boost::unordered_map<long, std::vector<float>*> mapLongFloat;
94  typedef boost::unordered_map<long, std::vector<int>*> mapLongInt;
95  std::string modelName;
96  boost::unordered_map<std::string, float> conversionFactorsToSI; //fetch variable name first, if using variable id instead
97  boost::unordered_map<std::string, std::string> variableSIUnits;
98  boost::unordered_map<std::string, std::vector<float>*> variableData;
99  boost::unordered_map<std::string, std::vector<int>*> variableDataInt;
100 
101  boost::unordered_map<long, std::vector<float>*> variableDataByID;
102  boost::unordered_map<long, std::vector<int>*> variableDataIntByID;
103 
109  virtual void initializeConversionFactorsToSI() = 0;
110 
111  void setBusyStatus(int busyStatus);
112 
116  virtual void initializeSIUnits() = 0;
117  std::string units_;
118 
121  int progress;
123 
124  };
125 }
126 #endif /* MODEL_H_ */